package com.skytech.tax.customsdatawarehouse.electronicport.customsdeclarations.domain.entity;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;

/**
 * 进出口关单 （电子口岸）
 */
public class CustomsDeclaration implements Serializable {

    private String entryId;                 //出口报关单号
    private String customsDeclaration;      //报关单信息
    private String storageTime;             //入库时间
    private String iEDate;                  //出口日期
    private String socialCreditCode;        //企业社会信用代码

    private String decType;
    private String flagDec;
    private String opMode;

    private String modifyTime;             //修改时间

    public CustomsDeclaration() {
    }

    public CustomsDeclaration(String entryId, String socialCreditCode, JSONObject customsDeclaration, String decType, String flagDec, String opMode) {
        this.entryId = entryId;
        JSONObject cardHeadVo = customsDeclaration.getJSONObject("cardHeadVo");
        this.iEDate = cardHeadVo.getString("iEDate");
        this.socialCreditCode = socialCreditCode;
        this.customsDeclaration = customsDeclaration.toJSONString();
        this.decType = decType;
        this.flagDec = flagDec;
        this.opMode = opMode;
    }

    public String getEntryId() {
        return entryId;
    }

    public void setEntryId(String entryId) {
        this.entryId = entryId;
    }

    public String getCustomsDeclaration() {
        return customsDeclaration;
    }

    public void setCustomsDeclaration(String customsDeclaration) {
        this.customsDeclaration = customsDeclaration;
    }

    public String getStorageTime() {
        return storageTime;
    }

    public void setStorageTime(String storageTime) {
        this.storageTime = storageTime;
    }

    public String getiEDate() {
        return iEDate;
    }

    public void setiEDate(String iEDate) {
        this.iEDate = iEDate;
    }

    public String getSocialCreditCode() {
        return socialCreditCode;
    }

    public void setSocialCreditCode(String socialCreditCode) {
        this.socialCreditCode = socialCreditCode;
    }

    public String getDecType() {
        return decType;
    }

    public void setDecType(String decType) {
        this.decType = decType;
    }

    public String getFlagDec() {
        return flagDec;
    }

    public void setFlagDec(String flagDec) {
        this.flagDec = flagDec;
    }

    public String getOpMode() {
        return opMode;
    }

    public void setOpMode(String opMode) {
        this.opMode = opMode;
    }

    public String getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(String modifyTime) {
        this.modifyTime = modifyTime;
    }

    /**
     * 关单号中年度 和 出口日期的年度 是否在同一年度
     * @return 是否同一年度
     */
    public boolean isSameYear() {
        String entryIdYear = StringUtils.substring(this.entryId, 4, 8);
        String iEDateYear = StringUtils.left(this.iEDate,4);
        return entryIdYear.equals(iEDateYear);
    }
}
